package com.ins.controller;

import com.ins.common.utils.Result;
import com.ins.model.entity.AppWalletLog;
import com.ins.service.AppWalletLogService;
import com.mybatisflex.core.paginate.Page;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.List;

/**
 * 用户钱包流水记录表
 *
 * @author ins
 * @since 2024-05-14
 */
@RestController
@RequestMapping("/wallet/log")
public class AppWalletLogController {

    @Resource
    private AppWalletLogService appWalletLogService;

    /**
     * 添加 用户钱包流水记录表
     *
     * @param appWalletLog 用户钱包流水记录表
     * @return {@code true} 添加成功，{@code false} 添加失败
     */
    @PostMapping("/save")
    public Result<Boolean> save(@RequestBody AppWalletLog appWalletLog) {
        return Result.ok(appWalletLogService.save(appWalletLog));
    }


    /**
     * 根据主键删除用户钱包流水记录表
     *
     * @param id 主键
     * @return {@code true} 删除成功，{@code false} 删除失败
     */
    @DeleteMapping("/remove/{id}")
    public Result<Boolean> remove(@PathVariable Serializable id) {
        return Result.ok(appWalletLogService.removeById(id));
    }


    /**
     * 根据主键更新用户钱包流水记录表
     *
     * @param appWalletLog 用户钱包流水记录表
     * @return {@code true} 更新成功，{@code false} 更新失败
     */
    @PutMapping("/update")
    public Result<Boolean> update(@RequestBody AppWalletLog appWalletLog) {
        return Result.ok(appWalletLogService.updateById(appWalletLog));
    }


    /**
     * 查询所有用户钱包流水记录表
     *
     * @return 所有数据
     */
    @GetMapping("/list")
    public Result<List<AppWalletLog>> list() {
        return Result.ok(appWalletLogService.list());
    }


    /**
     * 根据用户钱包流水记录表主键获取详细信息。
     *
     * @param id appWalletLog主键
     * @return 用户钱包流水记录表详情
     */
    @GetMapping("/getInfo/{id}")
    public Result<AppWalletLog> getInfo(@PathVariable Serializable id) {
        return Result.ok(appWalletLogService.getById(id));
    }


    /**
     * 分页查询用户钱包流水记录表
     *
     * @param page 分页对象
     * @return 分页对象
     */
    @GetMapping("/page")
    public Result<Page<AppWalletLog>> page(Page<AppWalletLog> page) {
        return Result.ok(appWalletLogService.page(page));
    }
}